package com.chuhe.starry.service.adapter;

import com.chuhe.common.domain.entity.UserContact;
import com.chuhe.common.domain.entity.UserContactApply;
import com.chuhe.common.domain.enums.UserContactStatusEnum;
import com.chuhe.common.domain.vo.req.ApplyAddReq;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @Author: 楚河
 * @Date: 2025年05月11日16:11
 */
public class UserContactAdapter {
    /**
     * 组装用户联系人
     * @Author: 楚河
     * @Date: 2025-05-11 16:12
     */
    public static UserContact buildUserContact(String userId) {
        UserContact userContact = new UserContact();
        userContact.setUserId(userId);
        userContact.setStatus(UserContactStatusEnum.FRIEND.getStatus());
        return userContact;
    }
    /**
     * 组装拉黑联系人
     * @Author: 楚河
     * @Date: 2025-05-16 20:39
     */
    public static UserContact buildBlackContact(UserContactApply applyInfo) {
        UserContact userContact = new UserContact();
        userContact.setUserId(applyInfo.getApplyUserId());
        userContact.setContactId(applyInfo.getContactId());
        userContact.setContactType(applyInfo.getContactType());
        Date date = new Date();
        userContact.setCreateTime(date);
        userContact.setStatus(UserContactStatusEnum.BLACKLIST_BE_FIRST.getStatus());
        userContact.setLastUpdateTime(LocalDateTime.now());
        return userContact;
    }
    /**
     * 组装查看群组人数
     * @Author: 楚河
     * @Date: 2025-05-17 10:57
     */
    public static UserContact buildSelectOnGroupCount(String contactId, Integer status) {
        return UserContact.builder()
                .contactId(contactId)
                .status(status)
                .build();
    }
    /**
     * 组装 申请人添加接受人
     * @Author: 楚河
     * @Date: 2025-05-17 11:09
     */
    public static UserContact buildAddReceiveUserContact(String userId, String contactId, Integer contactType, Date date) {
        return UserContact.builder()
                .userId(userId)
                .contactId(contactId)
                .contactType(contactType)
                .createTime(date)
                .status(UserContactStatusEnum.FRIEND.getStatus())
                .lastUpdateTime(LocalDateTime.now())
                .build();

    }
    /**
     * 接收人添加申请人
     * @Author: 楚河
     * @Date: 2025-05-17 11:14
     */
    public static UserContact buildReceiveAddUserContact(String receiveUserId, String userId, Integer contactType, Date date) {
        return UserContact.builder()
                .userId(receiveUserId)
                .contactId(userId)
                .contactType(contactType)
                .createTime(date)
                .lastUpdateTime(LocalDateTime.now())
                .status(UserContactStatusEnum.FRIEND.getStatus())
                .build();
    }
    /**
     * 组装 查询联系人
     * @Author: 楚河
     * @Date: 2025-05-17 13:53
     */
    public static UserContact buildFindUserOrGroup(String userId, Integer type) {
        return UserContact.builder()
                .userId(userId)
                .contactType(type)
                .build();
    }
}
